fix: keep stepped range progress totals aligned#9582
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
All contributors have signed the CLA ✍️ ✅ |
There was a problem hiding this comment.
No issues found across 2 files
Architecture diagram
sequenceDiagram
participant User as User Code
participant PB as progress_bar()
participant PR as ProgressBar <br/>_progress.py
participant PBar as Progress <br/>bar component
User->>PB: progress_bar(range(0, 10, 2))
PB->>PR: __init__(collection=range, total=None)
PR->>PR: total_was_provided = (total is not None)
PR->>PR: total is None → infer total
alt No explicit total
PR->>PR: total = len(range) = 5
PR->>PR: collection is range →<br/>total_was_provided is False →<br/>skip step override
PR->>PR: step remains default 1
else Explicit total provided
User->>PB: progress_bar(range(0, 10, 2), total=10)
PB->>PR: __init__(collection=range, total=10)
PR->>PR: total_was_provided = True
PR->>PR: total = 10 (caller-provided)
PR->>PR: collection is range AND<br/>total_was_provided is True →<br/>step = collection.step = 2
end
PR-->>PB: ProgressBar instance
PB-->>User: ProgressBar instance
Note over User,PBar: Iteration
loop Over range(0, 10, 2)
User->>PR: next()
PR->>PBar: update(step=1)
PBar-->>PR: current += 1
PR-->>User: [0, 2, 4, 6, 8]
end
Note over User,PBar: Final state differs by branch
alt No explicit total
User->>PR: check progress.current, progress.total
PR-->>User: (5, 5) — tracks yielded items
else Explicit total
User->>PR: check progress.current, progress.total
PR-->>User: (10, 10) — step applied to caller's total
end
|
@GHX5T-SOL, please sign the CLA |
|
recheck |
|
I have read the CLA Document and I hereby sign the CLA |
| ) | ||
|
|
||
| if isinstance(collection, range): | ||
| if total_was_provided and isinstance(collection, range): |
There was a problem hiding this comment.
Thanks, but this could be an elif
Bundle ReportChanges will increase total bundle size by 95.79kB (0.38%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: marimo-esmAssets Changed:
|
22807be to
e7d0193
Compare
|
Rebased this branch on current Validation run locally:
I also tried the failing scratchpad integration test locally, but the local server fixture timed out before the test body because static assets are not built in this checkout, so the GitHub Actions rerun is the meaningful signal for that job. |
This pull request was authored by a coding agent.
Summary
mo.status.progress_bar(range(...))whentotalis inferred, so stepped ranges track the number of yielded items instead of advancing past the inferred total.range.stepis used with the caller-provided total.range(0, 10, 2).Closes #9575.
Validation
uv run --group test pytest tests/_plugins/stateless/status/test_progress.py -q(15 passed)uv run ruff check marimo/_plugins/stateless/status/_progress.py tests/_plugins/stateless/status/test_progress.pyuv run ruff format --check marimo/_plugins/stateless/status/_progress.py tests/_plugins/stateless/status/test_progress.pyuv run --only-group typecheck mypy marimo/_plugins/stateless/status/_progress.pygit diff --checkgit diff | gitleaks stdin --no-banner --redact --timeout 30Limitations